package com.wanxi.set;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class StudentTreeSetArgs {
    public static void main(String[] args) {
        Set<Student> set = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
//                return o1.getAge() - o2.getAge();
                System.out.println("bb");
                return o1.getAge().equals(o2.getAge()) ? o1.getName().compareTo(o2.getName()) : o1.getAge() - o2.getAge();
            }

        });
//        Set<Student> set = new TreeSet<>(((o1, o2) -> o1.getAge().equals(o2.getAge()) ? o1.getName().compareTo(o2.getName()) : o1.getAge() - o2.getAge()));
        set.add(new Student("aa", 11));
        set.add(new Student("dd", 11));
        set.add(new Student("cc", 11));
        set.add(new Student("bb", 11));
        System.out.println(set);
    }
}
